﻿using System;
namespace Xtee.Riik.Ee.Xsd.Xtee {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="invalidInput", Namespace="http://x-tee.riik.ee/xsd/xtee.xsd", Target=typeof(InvalidInput))]
    public class InvalidInputSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IInvalidInput clazz;
        
        public InvalidInputSerializer(IInvalidInput clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("faultCode");
            if (clazz.FaultCode!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.FaultCode))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : FaultCode");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("faultString");
            if (clazz.FaultString!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.FaultString))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : FaultString");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="faultCode") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>invalidInput>faultCode");
                }
                clazz.FaultCode = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("faultCode")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>invalidInput>faultCode", Reader.LocalName);
            }
            if (Reader.LocalName=="faultString") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>invalidInput>faultString");
                }
                clazz.FaultString = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("faultString")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>invalidInput>faultString", Reader.LocalName);
            }
        }
    }
}
